<?php 
    if($this->ma == 2){
        echo '<script language="javascript" type="text/javascript">alert("只有已付款未处理的代充值能退款！");</script>';
    }else if($this->ma == 1){
        echo '<script language="javascript" type="text/javascript">alert("退款成功！");location.href = "/admini/managepay/chargedetail/id/'.$this->chargeItem->id.'";</script>';
    }
    $Item = $this->chargeItem;
    if($Item){
?>
<div class="yundanjiben">
    <div class="lmh4">
        <font size="4">代充值基本信息:</font>
    </div>
    <br/>
    <hr/>
    <br/>
    <div class="jibenleft">
        <table width="600px" border="1px soilder">
            <tr height="36px">
                <td class="tz" align="right">状态： </td>
                <td style="font-size: 20px;color: #c00;font-weight: 900;padding: 0px 0 0 10px;">　<?= htmlspecialchars($Item->statuscaption);?></td>
            </tr> 
            <tr height="36px">
                <td class="tz" align="right">用户名： </td>
                <td>　<?php if($Item->userinfo) echo htmlspecialchars($Item->userinfo->nikename); else echo '';?></td>
            </tr>
            <tr height="36px">
                <td class="tz" align="right">金额： </td>
                <td>　￥<?php echo number_format($Item->amount+$Item->serviceFee,2)."(手续费：".number_format($Item->serviceFee,2).")";?></td>
            </tr>
            <tr height="36px">
                <td class="tz" align="right">提交时间： </td>
                <td>　<?= htmlspecialchars($Item->dateCreated);?></td>
            </tr> 
        </table>
    </div>
    <div class="jibenright">
        <table width="600px" border="1px soilder" style="margin-top:20px;">
            <tr height="36px">
                <td class="tz">&nbsp;</td>
                <td></td>
            </tr> 
            <tr height="36px">
                <td class="tz" align="right">处理人：</td>
                <td>　<?= htmlspecialchars($Item->realname);?></td>
            </tr>
            <tr height="36px">
                <td class="tz" align="right">支付宝账号：</td>
                <td>　<?= htmlspecialchars($Item->useraccount);?></td>
            </tr>
            <tr height="36px">
                <td class="tz" align="right"><?php echo $Item->status == Application_Model_topUpAlipay::STATUS_Refund?"退款时间":"支付时间"; ?>：</td>
                <td>　<?= htmlspecialchars($Item->dateProcee);?></td>
            </tr>
        </table>
    </div>
    <div style="clear:both"></div>
</div>
<?php if($this->issuedetail){?>
    <div class="wenti">
        <div class="yuanyin">
            <h3><?= htmlspecialchars($this->issuedetail->title);?></h3>
            <p><?= htmlspecialchars($this->issuedetail->content);?></p>
        </div>
        <div class="yyxiugai">
            <a href="javascript:void(0)" id="editissue"><button>修改</button></a>
        </div>
    </div>
<?php }?>
<div class="tanchuang" style="display:none;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd">问题代充值</div>
        <a class="nui-msgbox-close" title="关闭" id="exitissue"><b></b></a>
    </div>
    <div class="neirbox">
        <form method="post" action="/admini/managepay/chargedetail/id/<?php echo $Item->id;?>" id="formissue">
	<table>
            <tr>
            	<td class="askl">问题类型：</td>
                <td>
                    <ul>
                    	<li><label><input name="issuetype" id="issuetype" type="radio" value="账号错误" <?php echo $this->issuedetail?$this->issuedetail->issuetype=="账号错误"?"checked":"":"checked"; ?> />账号错误</label></li>
                    	<li><label><input name="issuetype" id="issuetype" type="radio" value="金额错误" <?php echo $this->issuedetail?$this->issuedetail->issuetype=="金额错误"?"checked":"":""; ?> />金额错误</label></li>
                    	<li><label><input name="issuetype" id="issuetype" type="radio" value="金额超额" <?php echo $this->issuedetail?$this->issuedetail->issuetype=="金额超额"?"checked":"":""; ?> />金额超额</label></li>
                    	<li><label><input name="issuetype" id="issuetype" type="radio" value="其他问题" <?php echo $this->issuedetail?$this->issuedetail->issuetype=="其他问题"?"checked":"":""; ?> />其他问题</label></li>
                    </ul>
                </td>
            </tr>
        	<tr>
            	<td class="askl">标题：</td>
                <td>
                	<input class="input w400" type="text" id="issuetitle" name="issuetitle" value="<?php echo $this->issuedetail?$this->issuedetail->title:"【账号错误】代充值".$Item->id."号，有疑问请联系在线客服";?>" />
                </td>
            </tr>
        	<tr>
            	<td class="askl">问题描述：</td>
                <td>
                	<textarea id="issuecontent" name="issuecontent"><?= htmlspecialchars($this->issuedetail?$this->issuedetail->content:"") ?></textarea>
                </td>
            </tr>
        	<tr>
            	<td class="askl">信息提醒：</td>
                <td>
                    <ul>
                    	<li><label><input name="mail" id="mail" type="checkbox" value="mail" />邮箱提醒</label></li>
                    	<li><label><input name="message" id="message" type="checkbox" value="message" />站内信提醒</label></li>
                    </ul>
                </td>
            </tr>
        </table>
        <div class="neirboxok">
            <input type="hidden" id="chargeid" name="chargeid" value="<?php echo $Item->id;?>" />
            <input type="hidden" id="operate" name="operate" value="subcharge" />
            <input type="hidden" id="userid" name="userid" value="<?php echo $Item->userId;?>" />
            <a class="anvbotton" href="javascript:void(0)" id="subcharge"><span>确认提交</span></a>
        </div>  
        </form>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>
<div class="yundancaozuo2" style="width: 70%;margin-left: 100px;">
        <div class="yundancaozuo">
            <ul>
                <li style="margin-top:10px;"><a href="javascript:void(0)" id="refund"><span><button style="width:62px;height:28px;">退款</button></span></a></li>
                <li style="margin-top:10px;"><a href="/admini/managepay/charge/status/<?php echo Application_Model_topUpAlipay::STATUS_WaitPay;?>"><span><button style="width:62px;height:28px;">返 回</botton></span></a></li>
            </ul>
        </div>
</div>
<?php 
    }else{
        echo "暂无数据";
    }
?>
<script type="text/javascript">
    $("#subcharge").live("click",function(){
        var title = $("#issuetitle").val();
        var content = $("#issuecontent").val();
        if(title == ''){
            alert("标题不能为空！");
            return false;
        }else if(content == ""){
            alert("问题描述不能为空！");
            return false;
        }else{
            $('#formissue').submit();
        }
    });
    $("#refund").live("click",function(){
        <?php if($Item->status == Application_Model_topUpAlipay::STATUS_Processing){ ?>
            $("div.houtai_overlay").attr("style","display:block;");
            $("div.tanchuang").attr("style","display:block;");
        <?php }else{?>
            alert("只有已付款未处理的代充值能退款！");
        <?php }?>
    });
    $("#editissue").live("click",function(){
            $("div.houtai_overlay").attr("style","display:block;");
            $("div.tanchuang").attr("style","display:block;");
    });
    $("#exitissue").live("click",function(){
        $("div.houtai_overlay").attr("style","display:none;");
        $("div.tanchuang").attr("style","display:none;");
    });
    $("#issuetype").live("change",function(){
        var name = $(this).val();
        var title = $("#issuetitle").val();
        name = name=="其他问题"?" ":name;
        title = title.replace(/[^\【]+(?=\】)/g, name);
        $("#issuetitle").val(title);
    });
</script>